%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MCM/ICM LaTeX Template %%
%% 2022 MCM/ICM           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\title{sssssss}
\date{}
\usepackage{geometry}
\geometry{left=1in,right=0.75in,top=1in,bottom=1in}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replace ABCDEF in the next line with your chosen problem
% and replace 1111111 with your Team Control Number
\newcommand{\Problem}{C}
\newcommand{\Team}{2213980}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy} %fancyhdr宏包新增的页面风格
\fancyhf{}
\usepackage{newtxtext}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{newtxmath} % must come after amsXXX
\usepackage{lipsum}
\usepackage[pdftex]{graphicx}
\usepackage{xcolor}
\usepackage{fancyhdr}
\usepackage{biblatex}
\addbibresource{ref.bib}
\usepackage{appendix}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage[section]{placeins}
\usepackage{float} 
\usepackage{wallpaper}
%%%%%%引用代码
\usepackage{listings} 
\usepackage{xcolor}
\usepackage[algo2e,ruled,vlined]{algorithm2e}

\lstset{
  language=Matlab,  %代码语言使用的是matlab
  frame=shadowbox, %把代码用带有阴影的框圈起来
  rulesepcolor=\color{red!20!green!20!blue!20},%代码块边框为淡青色
  keywordstyle=\color{blue!90}\bfseries, %代码关键字的颜色为蓝色，粗体
  commentstyle=\color{red!10!green!70}\textit,    % 设置代码注释的颜色
  showstringspaces=false,%不显示代码字符串中间的空格标记
  numbers=left, % 显示行号
  numberstyle=\tiny,    % 行号字体
  stringstyle=\ttfamily, % 代码字符串的特殊格式
  breaklines=true, %对过长的代码自动换行
  extendedchars=false,  %解决代码跨页时，章节标题，页眉等汉字不显示的问题
  escapebegin=\begin{CJK*},escapeend=\end{CJK*},      % 代码中出现中文必须加上，否则报错
  texcl=true}


\lstset{breaklines}%自动将长的代码行换行排版

\lstset{extendedchars=false}%解决代码跨页时，章节标题，页眉等汉字不显示的问题
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\lhead{Team \Team}
\cfoot{}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}

\bibliography{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\graphicspath{{.}}  % Place your graphic files in the same directory as your main document
\DeclareGraphicsExtensions{.pdf, .jpg, .tif, .png}
\thispagestyle{empty}
\vspace*{-16ex}
\centerline{\begin{tabular}{*3{c}}
	\parbox[t]{0.3\linewidth}{\begin{center}\textbf{Problem Chosen}\\ \Large \textcolor{red}{\Problem}\end{center}}
	& \parbox[t]{0.3\linewidth}{\begin{center}\textbf{2022\\ MCM/ICM\\ Summary Sheet}\end{center}}
	& \parbox[t]{0.3\linewidth}{\begin{center}\textbf{Team Control Number}\\ \Large \textcolor{red}{\Team}\end{center}}	\\
	\hline
\end{tabular}}
%%%%%%%%%%% Begin Summary %%%%%%%%%%%
% Enter your summary here replacing the (red) text
% Replace the text from here ...
$$\Large \text{Don't Show Hand!:A Investment model Based on The CVaR}$$
\begin{abstract}
\\
  With the rise of quantitative trading, investors use a variety of quantitative trading strategies to improve their
   returns and reduce risks. In order to establish an investment strategy that only relies on historical price data
    to predict the future price trend and formulate investment strategy, we have determined three important objectives:
     to establish a price prediction model, a portfolio planning model, and analyze the impact of transaction costs on 
     the model. Firstly, this paper analyzes and predicts the time series data containing high-frequency signal and 
     low-frequency signal by using \textbf{wavelet analysis and hybrid prediction model}. Then, by introducing \textbf{CVaR}
     and constructing the discrete loss function of risk control, the optimal portfolio model under different conditions 
     is established.\\
  We solved the first problem by establishing the \textbf{ARIMA-SVM} prediction model .Considering that the price series
   is a kind of unstable, complex and difficult to predict time series data, in which there are linear laws and nonlinear
    laws respectively, we hope to use appropriate prediction models for these two parts. Firstly, we use the 
    \textbf{wavelet analysis}based on Mallat algorithm, and use the principle of wavelet decomposition to decompose the 
    historical price into high-frequency part and low-frequency part. The high-frequency signal will show the law of volatility
     in local historical prices, and the time series can be fitted by ARIMA algorithm. The low-frequency part will reflect the 
     overall trend of different assets. We use SVM regression method to fit the low-frequency part. 
     %Finally, the fitting prediction
     % results of the two parts can be reused by the principle of wavelet reconstruction to obtain more accurate prediction values, 
     % and the historical prediction window can be moved according to this principle, so as to realize the construction of prediction
     %  model. 
       In terms of SVM fitting, because the historical data is limited in the early stage, so we also use the 
       \textbf{SMO algorithm} and the \textbf{Bayesian optimized method} to ensure the robustness and repeatability of the model 
       The final prediction effect is very accurate. The RSMA for gold price prediction is 8.3214 and the RSMA for gold price 
       prediction is 624.3413.\\
  In terms of portfolio planning, starting from the idea of "controlling risks and obtaining the highest return", 
  we build a portfolio planning model based on CVaR. Based on the characteristics of CVaR and its statistical significance
   in risk control, we construct the measurement of risk. Taking the maximum return as the objective function and limiting 
   risk as the constraint, we establish the programming model. The investment  problem is transformed into 
   a nonlinear optimization problem of asset portfolio, and solved by sequential quantitative programming algorithm. 
   We calculate the optimal asset weight of different assets when we obtain higher return expectation under the specified 
   confidence level $\beta$ and risk level $\Omega$, and further design the decision of investment proportion conversion, 
   asset selling and buying with the help of the idea of greedy algorithm. Considering that gold can not be traded every 
   day, we divide the trading day into three kinds and establish different models respectively. Through the simulation of the given data, when the principal is US $\$$1000, the algorithm will be executed for 
   about four years, and our final assets are US $\$$3162.07, with an annual return of 33.35$\%$ \\
  Finally, we deeply analyze the advantages and disadvantages of the model. The superiority of the model 
  is proved by applicability analysis, market analysis, risk index analysis as well as disturbance data test. 
  After the sensitivity analysis of the model, it is found that there is an approximate linear relationship between 
  transaction cost and proceeds. When the proportion of commission increases to a certain extent, the proceeds will 
  decrease to 0. \\
\textbf{Keywords: } CVaR; ARIMA-SVM; Wavelet analysis ;
\end{abstract}

% to here
%%%%%%%%%%% End Summary %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\pagestyle{fancy}
% Uncomment the next line to generate a Table of Contents
%\tableofcontents 
\newpage

\tableofcontents

\newpage
\setcounter{page}{1}
\rhead{Page \thepage\ of \pageref{LastPage}}%当前页 of
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
\subsection{Problem Background}
Nowadays, gold and bitcoin are two of the hottest volatile assets. According to relevant data, the total bitcoin market has reached about 160 billion in just 10 years since its birth. In addition, under novel coronavirus pneumonia, the uncertainty of the financial market is increasing. Many investors have increased investment in the gold market in search of a so-called "Haven". The bitcoin and gold markets have achieved great development.It seems that investing in bitcoin and gold is a wise choice.\\
To obtain benefits in the process of investing in volatile assets, investors need to know changes in the price of the assets, so that they can buy assets when the prices are low and sell them when the prices are high. However, the prices of these volatile assets are affected by many factors,which are highly unstable, complex, and unpredictable time-series data. Therefore, to enable investors to obtain the maximum profit, it is very important to accurately predict the price changes and reasonably select the investment scheme.
\subsection{Problem restatement}
Considering the background information and relevant constraints, we need to solve the following problems:
\begin{itemize}
\item Establish a model that gives the best daily trading strategy only based on the price data up to that day.
\item Calculate the total value of the initial 1000  on October 9,2021, based on the model established.
\item Analyze the impact of transaction costs on investment strategies and the results.
\end{itemize}
\subsection{Literature Review}
The main problem we need to solve is to establish a model to predict assets prices and make the choice of investment strategies. In time-series analysis,using ARIMA-SVM model to process time-series data is a hot topic in recent years. Many scholars have made great contributions in this field. Zhenwei Li et al. improved the ARIMA model by using the deep learning model and predicted the high-frequency financial time- series data,which not only enriches the models for predicting time-series data, but also provides an effective tool for high-frequency strategy design\cite{2020On}. Manish Kumar and m. thenmozhi developed three different hybrid models combined with linear ARIMA and nonlinear models such as support vector machines (SVM), artificial neural network (ANN) and random forest (RF) models to predict stock indexes returns. The results show that the hybrid model of the ARIMA and the SVM achieves the highest prediction accuracy and better returns \cite{2014Forecasting}. Ping Feng Pai * and Chih Sheng Lin proposed a hybrid method by taking the unique advantages of ARIMA model and the SVM model, and used this method to predict the stock prices \cite{Ping2005A}. In terms of CVaR model, Meng Zhi Qing established a real estate portfolio model based on the dynamic CVaR model, and calculated investment proportion and risk losses of portfolio by using data of real estate of 10 cities in China.\cite{2007Risk}. The above researches provide a wide range of ideas for our model establishment.


\subsection{Our Work}
To solve the above problems,we mainly build two models:
Our main work contains two main parts.First model is based  on the ARIMA-SVM to predict the future price of 
gold and bitcoin,and the Second model is a  onstrained nonlinear programming combined with CVar theory ,
which is  to determine the daily trading strategy ,and we will prove that it's the best.\\
\begin{itemize}
  \item To determine the trading strategy, it is essential to "become a prophet" .At first, we simply use ARIMA model to analyze the time series of data and get the predicted value of each day's price, but the result is a little unsatisfying. Therefore, we combine the ARIMA and the SVM for prediction. Then,we do the wavelet transform of the sequence based on Mallat algorithm, and predict the high-frequency signal part with ARIMA model, while the low-frequency signal part with the SVM model.After that, we synthesize the results of two parts to generate the final prediction of the prices. \\
  \item For the choice of trading strategy, we think that it is important to consider the maximum profit as well as the risk.In order to maximize the revenue, we adopt the idea of greedy algorithm to optimize the profit of everyday.Using the predicted data obtained by the frist model, we construct the objective function of daily revenue, and use the historical prices to establish the constraints on risk. At the same time, considering that the gold trading market is not open every day, we put forword three different solutions for different situations. Finally, we get the best daily strategy and the investment value on September 10, 2021 when the initial investment is $\$$1000 on November 9,2016.\\
  \item In order to prove that our model provides the best strategy, we disturb the data and find that the rate of yield is relatively stable.Then,we analyze the profit situation of our model and its ability to resist the sharp change of assets prices. Finally, it is proved that our models perform well in the fields of resisting risk and obtaining profit.\\
  %Generally speaking,the two main parts of our work can be shown in the following chart:
\end{itemize}

\begin{figure}[ht]
  \centering
  \includegraphics[scale=0.6]{lax\\liuchengtu}
  \caption{}
  \label{fig:pathdemo}
\end{figure}

\section{Assumptions and Justifications}
To simplify the given problem, we make the following basic assumptions, each of them is properly justified.
\begin{itemize}
\item \textbf{Assumption 1:The trading volume of gold and bitcoin is continuous rather than discrete in each transaction.}\\
Explanation: Considering the initial amount of capital given by the topic, the price of gold per ounce and the price of each bitcoin, we can't trade integer ounces of gold as in the actual transaction. The same is true for bitcoin transactions.
\item \textbf{Assumption 2: Market traders invest rationally, in other words, they will follow the prediction results and
 the strategy made by the model established, and will not trade freely because of their judgment or emotion.}\\
 Explanation: In the actual investment activities, the economic behavior taken by each market trader is trying to obtain its 
 maximum economic benefits at a minimum economic cost. Therefore, the purpose of investors we should consider is to obtain the
  maximum benefits. The behavior of investors is only determined by the changes in the prices of assets and is not disturbed 
  by other external factors.
\item \textbf{Assumption 3:The goal of any investor will be completed only by one transaction.}\\
Explanation: In practice, investors may buy a certain amount of assets and sell assets at the same time. Considering the factor of reducing the extra cost of the transaction,we can care about the situation that investors can complete the goal in  one transaction.\\
\end{itemize}
Explanation: In practice, investors may buy a certain amount of assets and sell assets at the same time. Considering the factor of reducing the extra cost of the transaction,we can care about the situation that investors can complete the goal in  one transaction.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Notations}
The main symbols used in this paper are shown in the table below:\\
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[H]
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{12mm}
  \centering
  \caption{Add caption}
    \begin{tabular}{cc}
    
    \hline
    symbol &Description\\
    \hline
    $c_0$ & Signal to be decomposed \\
    $C_i$ & Layer i low frequency signal reconstruction \\
    $D_j$ & Layer j high frequency signal reconstruction \\
    $x_1^0,x_2^0,x_3^0$  & Gold, bitcoin and dollar assets before each transaction \\
    $x_1,x_2,x_3$  & Gold, bitcoin and dollar assets after each transaction \\
    $p_1,p_2$  & Price of gold and bitcoin before trading \\
    $y_1,y_2$  & Predicted gold and bitcoin prices \\
    $c_1,c_2$  & Commission proportion of transaction \\
    $v_0$  & Total assets before transaction \\
    $\beta$  & Select the confidence level of the model \\
    $\omega$  & Risk level of the model \\
    $ w $  & Investment weight\\
    \hline

    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
\par
Note:There are some variables that are not listed here and will be discussed in detail in each section. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Model I:Arima-svm Prediction Model}

\subsection{Time Series Analysis}
To start with, we use time-series analysis to predict the price. We first use the difference method to smooth the data before the current trading day and then complete the white noise test and unit circle test. After that, we use the autocorrelation function (ACF) and partial autocorrelation function (PACF)to select the time-series model. ACF reflects the autocorrelation between one observation and another, including direct and indirect correlation information. PACF reflects the direct relationship between the observed value and its lag. The results are shown below.\par
From Figure 2 and Figure 3, we will use MA (2) model to predict the gold price.\par
\begin{figure*}[h]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{lax//acf_gold}
\caption{ACF of Gold}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{lax//pacf_gold}
\caption{PACF of Gold}
\end{minipage}
\end{figure*}
From Figure 4 and Figure 5, we will use MA (3) model to predict bitcoin price.\\
\begin{figure*}[h]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{lax//acf_bitcoin}
\caption{ACF of Bitcoin}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{lax//pacf_bitcoin}
\caption{PACF of Bitcoin}
\end{minipage}
\end{figure*}

The final image of the prediction result is as follows. It can be seen that the result is not so satisfactory:\\

\begin{figure*}[h]
  \centering
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=8cm]{lax//1pre_gold}
  \caption{Gold price forecast}
  \end{minipage}
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=8cm]{lax//1pre_bitcoin}
  \caption{Bitcoin price forecast}
  \end{minipage}
  \end{figure*}
RSMA(Root mean square error ) of Gold price forecast is 13.89136.\\
RSMA(Root mean square error ) of Bitcoin price forecast is 815.2742.\\

Considering that the price series is an unstable, complex and difficult to predict time series data, 
the single use of time series analysis can not get perfect results. Therefore, we will adopt the \textbf{combined 
prediction model} below, that is, apply various prediction methods to the sequence through appropriate combination, 
and give full play to the advantages of various prediction methods participating in the combination in 
the combined prediction model. Time series analysis has the advantages of mature technology and high precision, 
while support vector machine (SVM) is suitable for fast prediction of small samples \cite{111}, and has a 
good performance in predicting prices \cite{222}. Therefore, we combine the two methods, \textbf{ARIMA model is used 
to predict the high-frequency signal reconstruction of the sequence, and SVM model is used to predict the 
low-frequency signal reconstruction of the sequence.} Explore the linear law and nonlinear law respectively 
\cite{111}, and then combine them to expect better prediction effect.

\subsection{Wavelet Transform}
In order to process signals with different frequencies,we choose the Mallat algorithm to implement decomposition and reconstruction.\\
Decomposition algorithm:\\
Frist,we let the discrete signal to be decomposed be $C_0$. Then we use  $db1$ and $db2$ wavelet filters in the Daubechies extreme phase wavelets family to construct low-pass filter (H) and high-pass filter (G),and finally we decompose the signal $C_0$ into $d_1, d_2,..., d_j$ and $c_j$.\\

\begin{equation}
c_{j+1}=Hc_j,d_{j+1}=Gd_j,j=0,1,...,J
\end{equation}

Where $j$ represents the largest number of decomposition layers, which size depends on the number of historical price data.The decomposition process adopts the method of two decimation to keep the length of each layer consistent before and after wavelet decomposition, and then we can reconstructed it by inverse operation.\\

Reconstruction algorithm:\\
According to the decomposition algorithm in the previous part,we can get the dual operators of G and H, which are represented as $G^*$ and $H^*$ respectively. Then , we can use the following formula to reconstruct the signal after wavelet decomposition:
\begin{equation}
C_j=H^*C_{j+1}+G^*D_{j+1},\ j=J-1,J-2,...0
\end{equation}
After reconstructing $d_1$,$d_2$,...,$d_j$ and $c_j$,we can get $D_1$,$D_2$,...$D_j$ and $C_j$.Finally,we can get the reconstruction result represented as $X_ji$:
\begin{equation}
X=D_1+D_2+...+D_j+C_j
\end{equation}
Where $C_j$ is the result of low frequency signal reconstruction from layer $J$ and $D_j$ is the result of high frequency signal reconstruction from layer $J$.$D_i$ = {$d_{i1}$ , $d_{i2}$ ,...,$d_{iN}$} ,$C_j$={$c_{j1}$,$c_{j2}$,....,$c_{jN}$},$X_j$={$x_{j1}$,$x_{j2}$,....,$x_{jN}$}.
Therefore:
\begin{equation}
X_{ji}=d_{1i}+d_{2i}+...+d_{ji}+c_{ji}
\end{equation}

\subsection{SVM Prediction}
Support Vector Machine (SVM) is a classical classification model.It can find a hyperplane with the optimal maximum boundary interval  between different classes to classify the data based on the Lagrange principle\\
For the regression model, the optimization objective function is consistent with the classification model, but the constraints are different. We need to construct a loss function, and by using the loss function,we can reduce the distance between the sample points and the hyperplane effectively.The loss function we use is listed below:\

\begin{equation}
err\left( x_i,y_i \right) =\left\{ \begin{array}{l}
	0,\ \ \ \left| y_i-\omega f\left( x_i \right) -b \right|\ \le \ \varepsilon\\
	y_i-\omega f\left( x_i \right) -b-\varepsilon ,\ \ \ \left| y_i-\omega f\left( x_i \right) -b \right|\ge \varepsilon\\
\end{array} \right. 
\end{equation}

Since the amount of data $C_i$ we get from the entire period of the investment will not be too much, and there is a nonlinear relationship among the data, it is quite reasonable to use the SVM regression model. We also use the \textbf{SMO algorithm} and the textbf{Bayesian optimized method} to ensure the robustness and iteratibility of the model.
The following are the relevant parameters after fitting:
\begin{table}[H]
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{12mm}
  \centering
  \caption{Parameters of SVM}
    \begin{tabular}{ccc}
    \hline
     BoxConstraint & KernelScale & Epsilon \\ 
\hline
    0.15748 & 21.189 & 39.263 \\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%


\subsection{Resualt}
To sum up, we can determine the algorithm of arima-svm model:\\
\textbf{Step 1}: decompose and reconstruct the price data up to the current day through Mallat algorithm of wavelet transform to obtain:
\begin{equation}
{
X_ji=D_{ji}+c_ji
}
\end{equation}
\textbf{Step 2}: use ARIMA model to predict $D_{ji}$ and get $D_{ji}^*$.\\
\textbf{Step 3}:use SVM model to perdict $c_{ji}$ and get $c_{ji}^*$\\
\textbf{Step 4}:The final prediction result is obtained by synthesizing the above prediction results \cite{222}:\Biggl\Biggr\\
$$\hat{X}_i=D_{ji}^*+C_i^*$$

The predicted results are as follows:\\
\begin{figure*}[h]
  \centering
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=8cm]{lax//PredictOfGlod}
  \caption{Gold price forecast}
  \end{minipage}
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=8cm]{lax//PredictOfBit}
  \caption{Bitcoin price forecast}
  \end{minipage}
  \end{figure*}
RSMA(Root mean square error ) of Gold price forecast is 8.3214.\\
RSMA(Root mean square error ) of Bitcoin price forecast is 624.3413.\\
The above results prove that the prediction is more accurate after using arima-svm model
\section{Model II:Portfolio model based on CVaR}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{CVaR model description}
The VaR(Value at Risk) method is widely used in investment, which is a good model to measure risks by using the statistical idea. According to the model, the maximum possible loss of a portfolio in a future period at a certain probability level can be expressed as \cite{333}:
\begin{equation}
P\left( \varDelta v>VaR \right) =1-\beta
\end{equation}
However, it has certain limitations in mathematics, and can not deal with the situation of the market in the case of extreme price changes \cite{444}. In order to improve it, CVaR, conditional value at risk, is proposed. According to the research, CVaR can be used in the optimization algorithm of linear programming \cite{1999Optimization}, so CVaR can be used in the risk-benefit analysis model.\\
Let $f(x,y)$ be the loss function of portfolio to describe the loss of investment,where $x\in X$ represents a portfolio and $y$ represents the price of each asset of the portfolio.If we let the probability density function of $y$ be $p(y)$, we can get the following distribution function based on the definition of VaR:

\begin{equation}
\varPsi \left( x,\alpha \right) =\int\limits_{f\left( x,y \right) <\alpha}{p\left( y \right) dy}
\end{equation}

At the same time, we get\cite{2000Conditional}:

\begin{equation}
\alpha _{\beta}\left( x \right) =\min \left\{ \alpha \in R:\ \varPsi \left( x,\alpha \right) >\chi \right\} 
\end{equation}


\begin{equation}
F_{\beta}(x,\alpha)=\alpha +\left( 1-\beta \right) ^{-1}\int{\left( f\left( x,y \right) -\alpha \right) ^+p\left( y \right) dy}
\end{equation} 
It is easy to deduce from the above formula when $F_{\beta}$ takes its minimum value,$\alpha$ is VaR, and CVaR is the result of minimizing $F_{\beta}$ to $\alpha$. The solution $(x^{*},\alpha^{*})$ of the optimization problem is the optimal portfolio and VaR.
Because $p(y)$ is difficult to calculate, we use historical data to simulate and select $J$ past historical data $y^1,y^2...y^j$ , as the possible value at the end of the investment period. Then we introduce the dummy variable $z=f(x,y)-\alpha$  to replace the initial $F_{\beta}(x,\alpha)$ with the following linear function and linear constraint,which makes the optimization problem easier to solve:\cite{1999Optimization}

\begin{equation}
F_{\beta}\left( x,\alpha \right) =\alpha +\left( 1-\beta \right) ^{-1}\sum_{j=1}^J{z_j}
\end{equation}


\begin{equation}
z_j>f\left( x,y^j \right) -\alpha 
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ggG%%
\subsection{Establishment of CVaR dynamic programming model}
To get the maximum profit,we choose to adopt greedy algorithm. Specifically,by making good use of each price change, and trying to get the highest profit as much as possible every day under the condition of taking certain risks, we can get the best final results.Then, we will establish a dynamic programming model based on CVaR.\\
Due to the constraints on transaction date, we need to take all possible situations into consideration:\\

\textbf{Situation 1:The gold market is open now and will be open the next day as well.} According to the previous analysis, and taking the maximum daily profit as the optimization goal, we can establish the following planning model:
\begin{equation}
max\ R(x)=x_1y_1/p_1+x_2y_2/p_2+x_3-x_1^0-x_2^0-x_3^0-c_1|x_1-x_1^0|-c_2|x_2-x_2^0|
\end{equation}


\begin{equation}
\left\{ \begin{array}{l}
	v_0=x_1+x_2+x_3+c_1|x_1-x_{1}^{0}|+c_2|x_2-x_{2}^{0}|\\
	\alpha +\left( 1-\beta \right) ^{-1}\sum_{j=1}^Jz_j<\omega\\
	z_j\ge f(x,y^j)-\alpha\\
\end{array} \right. 
\end{equation}
\\
Where $x_1^0,x_2^0,x_3^0$ represent the daily assets of US dollars, gold and bitcoin before trading respectively, $v_0$ is the sum of $x_1^0,x_2^0,x_3^0$.$p_1$ and $p_2$ represent the price of gold and bitcoin now respectively, $y_1,y_2$ represent the predicted price of gold and bitcoin the next day respectively, $c_1=\alpha_{gold},c_2=\alpha_{Bitcoin}$ represent the commission proportion of each transaction.$\beta$ is the selected confidence level and $\omega$ is the risk level(the acceptable degree of loss). \\
In the above model, the first constraint is the constraint of capital, the second is the constraint of the loss risk, and the third is the constraint of $z$ through loss function and $\alpha$. If we get the optimal solution $(x^*,\alpha^*)$, then $x^*$ will be the optimal portfolio, $VaR=\alpha^*$.\\
\textbf{Situation 2: The gold market is open now but will close the next day.} Since there is no gold to be traded the next day, there is no information about the gold price the next day.To make it easier to discuss the impact of this situation, let \textbf{$y_1'$} be a virtual price for gold.Then we can know that on the one hand, if the price of bitcoin rises during that period but traders do not buy it timely, it is an obvious loss for traders. So $y_1'$ is obviously negatively correlated with the increase of bitcoin price. On the other hand, if the gold price will increase so significantly on the next gold trading day that the profit brought by gold may even far exceed that brought by bitcoin , then traders may not only retain gold, but also buy it. In this case, $y_1'$is positively correlated with the predicted price at the beginning of the next gold transaction period.\\
\\
In order to measure the impact of changes in the price of bitcoin and gold equally, we think it is reasonable to  use the rate of change in price,then we can get the following expression of gold virtual price $y_1'$:

\begin{equation}
y_1'=(\frac{y_{1,j}-p_1}{p_1}-\frac{y_{2,i+1}-p_2}{p_2}-\frac{y_{2,i+2}-y_{2,i+1}}{y_{2,i+1}}...-\frac{y_{2,j}-y_{2,j-1}}{y_{2,j-1}})\times p_1+p_1
\end{equation}
\\
Where i represents the current gold trading date, j represents the next gold trading date, $y_{1,j}$ is the predicted gold price on day $j$ and $y_{2,k}$ is the predicted price of bitcoin on day$k$ $(k=i+1,i+2,...j)$\\
Then, we can replace the $y_1$ in the model above with $y_1'$ to deal with situation 1.\\
\textbf{Situation 3: The gold market is closed.} Since gold can not be traded,we just need to consider the bitcoin transaction.We can remove  both the objective function and restrictions on gold from (13)(14) to get the following model:
\begin{equation}
  max\ R(x)=x_2y_2/p_2+x_3-x_2^0-x_3^0-c_2|x_2-x_2^0|
\end{equation}
  
  
  \begin{equation}
  \left\{ \begin{array}{l}
    v_0=x_2+x_3+c_2|x_2-x_{2}^{0}|\\
    \alpha +\left( 1-\beta \right) ^{-1}\sum_{j=1}^Jz_j<\omega\\
    z_j\ge f(x,y^j)-\alpha\\
  \end{array} \right. 
  \end{equation}
\\
After discussing the above three different situations, we can get the trading strategy: $x_1,x_2,x_3$, which represent the amount of gold, bitcoin and US dollar after the transaction and $\alpha$, which is used to measure the risk with model we construct.\\
The model established by the above formula can clearly show the detail of a investment allocation under the CVaR theory and a more quantitative portfolio.However, the model is only aimed at the calculation of specific values rather than the percentage allocation of the assets.This might bring two disadvantages:\\
\textbf{Frist:} the model may not meet the stability requirements in terms of sensitivity.\\
\textbf{Second:} the model may have different investment preferences for financial products with different prices.\\
Therefore,we optimize the model into the following matrix form:\\
\begin{equation}
  min \varPhi \left( w ,CVaR \right) =CVaR+\frac{1}{J\left( 1-\beta \right)}\sum_{j=1}^J{\left( f(w,T_j)-CVaR \right) ^+}
\end{equation}
\begin{equation}
  w =\left( w _1,w _2,...,w _n \right) ,T_j=Percentage \ of \ price \ change.
\end{equation}
Where $J$ represents the number of historical data selected. $CVaR$ can represent the level of risk and $w$ that represents investment weight of the model for different assets can replace the $x$ in the previous model. In this way we can avoid the impact produced by different unit prices of invesment objects.

\subsection{Weight coefficient strategy}
If we adopt the traditional linear programming algorithm, the problem may have no solutions since the objective function of CVaR algorithm is nonlinear. Therefore, we use constrained nonlinear programming instead and set random initial values to approximate the correct answer. Besides, when it comes to selecting algorithm, the inner point method that usually performs well in large scale sparse optimization problems and small dense optimization problems but may not be suitable for medium data scale problems.In this problem, since each prediction only involves the balance between the two assets(gold and bitcoin), we adopt the sequential quantitative programming algorithm which is more suitable for medium data scale.\\
After calculating CVaR, we can describe the current investment risk based on its value and formulate the following investment strategies:\\
If the value of CVaR tends to be 0,which means that the prospect of investment is very good, the trader can actively invest and allocate the investment according to the weight percentage of the two assets.\\
If the value of CVaR tends to be far from 0,which means that the prospect of investment is not so good,the trader can determine the proportion of the current investment to his total investment based on the ratio of CVaR to the previous random range.\\
During the period when the gold market is closed,we need to introduce the gold's virtual price $y_1'$ and get two virtual weights.The two weights can determine the structural adjustment of bitcoin and total assets other than gold respectively,which reduces the influence of the closed gold market and the potential fluctuation of gold price.\\
So far, we have completed the complete quantitative prediction process.The pseudo code we get is shown below:\\
\begin{algorithm2e}[h]
  
  \SetAlgoLined
  \KwIn{Portfolio returns matrix and Forecast rise and fall of the next day}
  %\KwData{Portfolio returns matrix and Forecast rise and fall of the next day}
  \KwResult{Quantitative strategy decision for  days }

  initialization\;

  \For{The First Investment day \KwTo The Last Investment day}{
    Calculate the current total value of assets through today's market\;
    Calculate the $CVaR$ value and the investment weight $\omega_1,\omega_2 $ of gold and bitcoin through historical data and the predicted value of the next day\;
    Total planned investment assets today   = Cvar / historical max Cvar * Total assets\;
    \eIf{The gold market is not closed}{
      Planned gold investment =  $ \left[ \omega_1  \div ( \omega_1 + \omega_2 )  \right]  \times Total planned investment $\; 
      Planned bitcoin investment = $\left[ \omega_2 \div ( \omega_1 + \omega_2 )  \right]  \times Total planned investment $ \;
      }{
        Get virtual gold price forecast;\;
        Planned gold investment =  $ \left[ \omega_1  \div( \omega_1 + \omega_2 )  \right]  \times Total planned investment $ \;
    }

    Do the investing process and  Deduct handling charges

  }
  \caption{Investment strategy algorithm based on CVaR}
\end{algorithm2e}

\section{Conclusion}
Through the establishment of the above model, we have completed the whole process from data processing to investment prediction. After about four years of quantitative operation, the total principal of US $\$$1000 has become about US $\$$3162.07, and the annual return has reached 33.35$\%$ ;Facts have proved that the data predicted by the above ARIMA-SVM combined model is not only close to the real value, but also can play a guiding role in the subsequent CVaR strategy model. The mallet decomposition method can highlight the high-frequency part of the data and improve the anti-interference kinetic energy of the model.\\
In order to prove that our model is optimal under the same confidence level $\beta$ and risk level $\omega$, we make some disturbances on the original data, and the results are still stable, that is, the annual return remains between 25 $\%$ and 40 $\%$. At the same time, we note that in May 2021, when the price of bitcoin plummeted, our model sold bitcoin in time and bought a large amount of rising gold, which proves the ability of the model to resist the crisis. In January 2021, when the price of bitcoin is rising rapidly, the model can seize the opportunity to buy a lot of bitcoin and obtain good profits, which proves the ability of the model to obtain income.\\
\begin{figure}[ht]
  \centering
  \includegraphics[scale=0.3]{lax\\beta = 0.95}
  \caption{Investment portfolio}
  \label{fig:pathdemo}
\end{figure}

\begin{figure}[ht]
  \centering
  \includegraphics[scale=0.6]{lax\\zuiyou}
  \caption{Comparison with other models}
  \label{fig:pathdemo}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Sensitivity Evaluation of Model}
We perturb  $\alpha_gold$,$\alpha_bitcoin$ by 10 $\%$ to obtain the relationship between the change of commission rate and the change of annualized interest rate:
\begin{figure*}[h]
  \centering
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=6cm]{lax//Sensitivityofgold}
  \caption{Commission rate and the change of annualized interest rate}
  \end{minipage}
  \begin{minipage}[t]{0.48\textwidth}
  \centering
  \includegraphics[width=6cm]{lax//Sensityvitybit}
  \caption{Commission rate and the change of annualized interest rate}
  \end{minipage}
  \end{figure*}
  For our model, the change of commission rate is roughly linear with the annualized interest rate, and there is no drastic change. The higher the Commission, the lower the income. When the commission rate exceeds a certain value, the income even becomes negative. This means that the revenue generated by the transaction is not enough to pay the Commission. The number of transactions will be greatly reduced.\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Strengths and weaknesses}
\subsection{Strengths}
\begin{itemize}
\item \textbf{Strength-1 More accurate:Our model makes full use of the two methods.}
Specifically, we use wavelet analysis to divide price-series into high-frequency signals and low-frequency signals, and then fit the linear part and nonlinear part of the sequence with the ARIMA method and the SVM method respectively,which makes the prediction on prices more accurate.\\

\item \textbf{Strength-2 Robustness:When choosing the portfolio, we do not blindly pursue the highest return.} Instead,we adopt the idea of greedy algorithm on the basis of fully considering and limiting the risk, which makes our model have better performance on resisting risk and maintaining income, thus has better robustness.\\

 \item \textbf{Strength-3 Better applicability:Our model makes it easier for traders to realize the risk hidden in the investment with the help of VaR and confidence level given by the CVaR model.} At the same time,they can get the portfolio that fits their own conditions well by changing the confidence level and the risk level.So,our model can be applied more widely.\\
\end{itemize}

\subsection{weakness}

Introduction of subjective factors:During the period of establishing the model,there are some hyperparameters to determine based on the actual situations.These hyperparameters include the expected rate of return, the random initial value range given when solving nonlinear programming, and the number of historical stock prices input when calculating CVaR,which need to be set by traders through experience and their own judgment.

\newpage
\section{Memo}
%\CenterWallPaper{0.75}{lax\\background}
\textbf{To:Trader}\\
\textbf{From:MCM Team 2213980}\\
\textbf{Data:Feb 21th,2022}\\
\textbf{Subject:Description of portfolio model}\\
Dear Sir:\\
With the fast growth of the gold market and the bitcoin market, many people choose to invest in bitcoin and gold. In our work, we have built two models in hope to help you maximize your profit in the future and minimize the risk of investment:\\
The frist model we established is a price forecasting model based on the ARIMA model and the SVM model.In order to improve the prediction accuracy, we carried out wavelet analysis on the price series, and use the ARIMA model and the SVM model to predict the high-frequency part and low-frequency part respectively. After that,we synthesized the two parts of results to obtain the final predicted data. Using this prediction model, you can accurately predict the price of tomorrow or even the next few days through the past price data, which can provide a reference for your decision-making.\\
The second model we established is a portfolio model based on CVaR.Based on the prediction model, we adhered to the principle of "Pursuing the highest interest under a certain level of risk", and limited the risk with two parameters: confidence level $\ beta $and risk level $\ Omega $. Their meaning is that under the probability of $\ beta $, the loss will not exceed $\ Omega $. In order to measure the risk, we used some historical data as simulation and the calculated value of CVaR to judge the investment tendency and control the risk. Finally, we took the risk as the constraint and the highest profit as the goal to establish the planning model.Considering that gold market is not open every day, there are three different models on three different situations.\\
Here are the results we got:\\
With the confidence level of $\ beta = 0.95 $, and the risk level of $\ omega = 0.1 $, if you follow the strategy made by our models, you will get US $3162.07 with the initial $1000 investment on September 9, 2021.When it comes to the sensitivity of the model,for the change of commission, the result of the model will be affected linearly without drastic change.Specifically, when the commission is higher, the revenue is lower. When the commission exceeds a certain level, the revenue will become negative and the frequency of transactions will be greatly reduced.\\
In the early stage of investment, assets transformation is slow at first, and then rises rapidly.At the same time,the number of bitcoins has also increased significantly,which is consistent with the rapid rise of bitcoin price and the long-term stability of gold price.\\
In the medium stage of the investment, there will be slow but lasting losses, and the proportion of gold and bitcoin is relatively same, which is related to the downturn of gold and bitcoin during that period.\\
In the later stage of the investment, our models makes good use of the opportunity of the sharp rise of bitcoin price and sells bitcoin in time to avoid the loss caused by the sharp decline of its price,which increases the total \\
It is worth noting that the holdings of US dollars have been relatively low throughout the whole investment process. This is because the risk level $\ Omega $we set is 0.1, which represents a relatively high risk tolerance. Therefore, the model will tend to invest rather than hold dollars.\\
The models and the results above will help you better invest in bitcoin and gold market.We sincerely hope that our study will benefit you a lot!\\
\qquad \qquad \qquad\qquad\qquad\qquad\qquad\qquad \qquad\qquad\qquad\qquad\qquad Sincerely,
\qquad \qquad \qquad\qquad\qquad\qquad\qquad\qquad \qquad\qquad\qquad\qquad\qquad Team 2213980






\printbibliography
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newpage
\section{Appendices}
\appendix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{Main code of CVaR model}
\begin{lstlisting}
  day = length(trend);
  Cap = 1000;
  process = zeros(day,3);
  process(58,1) = 0;
  process(58,2) = 0;
  process(58,3) = Cap;
  gold_real = trend(:,3);
  gold_pre = trend(:,4);
  bit_real = trend(:,1);
  bit_pre = trend(:,2);
  gold_holy_pre = trend(:,6);
  alldata = [bit_real,gold_real,bit_pre,gold_real];
  gold_RATE = 0.01;
  BIT_RATE = 0.02;
  R0=0.1;
  Rick_w = 100; 
  Cvar = zeros(1,3);
  W = zeros(1,1);
  for i = 59:day-1
  Sentrix = [alldata(i-30:i,1:2);alldata(i+1,3:4)];
  [ww,fval] = CVaROptimization(Sentrix,[0.5,0.5]*Rick_w,R0,[],0.96,1,-0.1);
  Cvar(i-58,:) = fval(:);
  W(i-58) = ww;
  end
  figure
  plot(Cvar(:,1),'*');hold on ;
  plot(Cvar(:,2),'*');hold on ;
  
  legend('bit','gold');
  figure;
  plot(W);
  mean(W);
  disp("1")
  
  maxvar = max(W);
  for i = 59:day-1
  j = i-58; 
  process(i,1) = process(i-1,1)*(1+ bit_real(i) );
  if(gold_real(i)~=0)
  process(i,2) = process(i-1,2)*(1+ gold_real(i) );
  else 
  process(i,2) = process(i-1,2);
  end
  process(i,3) = process(i-1,3);
  today_money = sum(process(i,:));
  bit_fac = abs( Cvar(j,1)/(Cvar(j,1)+Cvar(j,2) ) );
  gold_fac = abs( Cvar(j,2)/(Cvar(j,1)+Cvar(j,2)) );
  if(gold_real(i)~=0)
  if(Cvar(j,3)<1)
  stock_money = today_money;
  process(i,1) = stock_money* bit_fac -abs(stock_money* bit_fac - process(i,1)) * BIT_RATE;
  process(i,2) = stock_money* gold_fac -abs(stock_money* bit_fac - process(i,1)) * gold_RATE;
  process(i,3) = 0 ;
  else
  stock_money = today_money * ( 1.01- Cvar(j,3)/maxvar ) ; 
  process(i,1) = stock_money* bit_fac -abs(stock_money* bit_fac - process(i,1)) * BIT_RATE;
  process(i,2) = stock_money* gold_fac -abs(stock_money* bit_fac - process(i,1)) * gold_RATE;
  process(i,3) = today_money- stock_money ;
  end
  else
  if( Cvar(j,3)<1)
  stock_money = today_money - process(i,2);
  process(i,1) = stock_money* bit_fac -abs(stock_money* bit_fac - process(i,1)) * BIT_RATE;
  process(i,3) = stock_money - stock_money* bit_fac ; 
  else 
  process(i,1) = process(i-1,1);
  process(i,2) = process(i-1,2);
  process(i,3) = process(i-1,3);
  end
  end
  % % 
  end
  
  \end{lstlisting}



  
\end{document}
%%
%% This work consists of these files mcmthesis.dtx,
%%                                   figures/ and
%%                                   code/,
%% and the derived files             mcmthesis.cls,
%%                                   mcmthesis-demo.tex,
%%                                   README,
%%                                   LICENSE,
%%                                   mcmthesis.pdf and
%%                                   mcmthesis-demo.pdf.
%%
%% End of file `mcmthesis-demo.tex'.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
